﻿using Microsoft.Practices.Unity;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;
using TestByWire.Factories.StubbingStrategies;

namespace TestByWire.Test.Factories.StubbingStrategies
{
    [TestClass]
    public class ActivatorStrategyTest
    {
        private ActivatorStrategy _activatorStrategy;

        [TestInitialize]
        public void PerTestSetup()
        {
            _activatorStrategy = new ActivatorStrategy();
        }

        [TestMethod]
        public void CanHandleTypeMustReturnTrueIfTypeIsValueType()
        {
            bool result = _activatorStrategy.CanHandleType(typeof(int), null);

            Assert.IsTrue(result);
        }

        [TestMethod]
        public void CanHandleTypeMustReturnFalseIfTypeIsRefType()
        {
            bool result = _activatorStrategy.CanHandleType(typeof(object), null);

            Assert.IsFalse(result);
        }

        [TestMethod]
        public void CanHandleTypeMustReturnFalseIfTypeIsString()
        {
            bool result = _activatorStrategy.CanHandleType(typeof(string), null);

            Assert.IsFalse(result);
        }

        [TestMethod]
        public void TryCreateInstanceMustReturnValidInstance()
        {
            var instance = _activatorStrategy.CreateInstance(typeof(int), null);

            Assert.IsInstanceOfType(instance, typeof(int));
        }

        [TestMethod]
        public void RegisterOnContainerMustReturnFalse()
        {
            Assert.IsFalse(_activatorStrategy.RegisterOnContainer);
        }
    }
}
